import pandas as pd
from tqdm import tqdm
from outline_gen_agents.outlines_graph import run_agent

df = pd.read_csv("test_data/input_instruments.csv")
new_data = []
for index,col in tqdm(df.iterrows(),total=len(df)):
    report_type,years,detail_type,field,audience_input,instrument = col
    try:
        state = run_agent(instrument)

        provider = state["provider"]
        user_input = state["user_input"]
        user_need = state["user_need"]
        goal = state["goal"]
        audience = state["audience"]
        domain = state["domain"]
        year = state["year"]
        data = state["data"]
        analysis_paradigm = state["analysis_paradigm"]
        outlines = state["outlines"]
    except:
        provider = 'None'
        user_input = 'None'
        user_need = 'None'
        goal = 'None'
        audience = 'None'
        domain = 'None'
        year = 'None'
        data = 'None'
        analysis_paradigm = 'None'
        outlines = 'None'


    new_data.append([report_type,years,detail_type,field,audience_input,provider,user_input,user_need,goal,audience,domain,year,data,analysis_paradigm,outlines])
pd.DataFrame(new_data,
             columns=["report_type","years","detail_type","field","audience_input","provider","user_input","user_need","goal","audience","domain","year","data","analysis_paradigm","outlines"]
             ).to_csv("test_data/data.csv",index=False)

pd.DataFrame(new_data,
             columns=["report_type","years","detail_type","field","audience_input","provider","user_input","user_need","goal","audience","domain","year","data","analysis_paradigm","outlines"]
             ).to_excel("test_data/data.xlsx",index=False)


